package com.smartlifev30.baiwei.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Scroller;
import android.widget.Toast;

import com.smartlifev30.R;
import com.smartlifev30.baiwei.adapter.ZoneAdapter;
import com.smartlifev30.baiwei.view.recyclerViewComponent.BaseAdapter;

import java.util.ArrayList;

/**
 * 家庭安防(在家, 外出, 睡眠, 一键撤防)
 *
 * @author tys
 */
public class ZoneTypeFragment extends Fragment {
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mParam1;
    private String mParam2;
    private RecyclerView recyclerView;
    private ZoneAdapter zoneAdapter;


    public ZoneTypeFragment() {
    }


    public static ZoneTypeFragment newInstance(String param1, String param2) {
        ZoneTypeFragment fragment = new ZoneTypeFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_zone, container, false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        recyclerView = view.findViewById(R.id.zone_recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        zoneAdapter = new ZoneAdapter(getContext(), new ArrayList<>());
        zoneAdapter.setItemClickListen((itemView, position) -> {
            Toast.makeText(getContext(), String.valueOf(position), Toast.LENGTH_SHORT).show();
        });
        recyclerView.setAdapter(zoneAdapter);
    }

}
